home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Source Code
/
Pascal
/
Code Resources
/
Eclectic CDEFs
/
CDEF Utilities
/
JumpCDEF Folder
/
JumpCDEF.p
< prev
next >
Wrap
Text File
|
1997-02-27
|
3KB
|
88 lines
{ JumpCDEF }
{}
{ Copyright © Sebastiano Pilla 1996 }
{ All rights reserved }
{}
{ Original C source code Copyright © 1991-1995 by James G. Stout }
{ <mailto:case@tvol.it> }
{ 1) Build this project as a CDEF with ID = 128 as file JumpCDEF.rsrc }
{}
{ 2) Include the CDEF and a custom resource of type 'CJMP', ID = 128 in }
{ the resource file of your test project. The 'CJMP' resouce should be any long }
{}
{ 3) Include your CDEF source code in a test project, but with an entry}
{ point of (say) MyCDEFProc instead of Main }
{}
{ 4) In your test source, where Main is found plug the address of }
{ CDEFmain into the 'CJMP' resource, like: }
{}
{ jmpHndl := CDEFJumpHandle(GetResource('CJMP', 128)); }
{ ChangedResource(Handle(jmpHndl)); }
{ HNoPurge(Handle(jmpHndl)); }
{ if jmpHndl <> nil then jmpHndl^^.fRealDefUPP := NewControlDefProc(@MyCDEFProc); }
{}
{ This is done automatically for you in the JumpCDEFIntf unit }
{}
{ 5) Use 128 as the CDEF ID in your resource templates. }
{}
{ If you have done things correctly, when the Control Manager tries to}
{ call CDEF 128, it gets this code instead, which recovers the address}
{ of MyCDEFProc and calls it. Then you can use a source-level debugger to debug }
{ the CDEF code. When it's working, change the CDEF entry point to build a standalone }
{ resource }
{ Note: THINK Pascal does not let you to assign IDs greater than 63 to "owned" resources like CDEFs. To }
{ overcome this limitation, build the CDEF in THINK Pascal with any ID you like, then change the ID of the }
{ just built CDEF resource in the resource file }
unit JumpCDEF;
interface
function Main (inVarCode: SInt16;
inControlHdl: ControlHandle;
inMessage: ControlDefProcMessage;
inParam: SInt32): SInt32;
implementation
const
kCDEFJumpResType = 'CJMP'; { resource type of the 'CJMP' resource }
kCDEFJumpResID = 128; { resource ID of the 'CJMP' resource }
type
CDEFJumpHandle = ^CDEFJumpPtr;
CDEFJumpPtr = ^CDEFJumpRec;
CDEFJumpRec = record
fRealDefUPP: ControlDefUPP;
end;
function Main (inVarCode: SInt16;
inControlHdl: ControlHandle;
inMessage: ControlDefProcMessage;
inParam: SInt32): SInt32;
var
jmpHdl: CDEFJumpHandle;
realDefUPP: ControlDefUPP;
resultCode: SInt32;
begin
resultCode := 0;
jmpHdl := CDEFJumpHandle(GetResource(kCDEFJumpResType, kCDEFJumpResID));
if jmpHdl <> nil then
begin
realDefUPP := jmpHdl^^.fRealDefUPP;
resultCode := CallControlDefProc(inVarCode, inControlHdl, inMessage, inParam, realDefUPP);
end;
Main := resultCode;
end;
end.